package com.adv.web.service;

import java.util.ArrayList;
import java.util.List;

import me.chanjar.weixin.common.bean.WxMenu;
import me.chanjar.weixin.common.bean.WxMenu.WxMenuButton;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;

public class MenuService {

	public static void createmenu(WxMpService wxMpService){
		
		// 设置菜单
		try {
			wxMpService.menuDelete();
			WxMenuButton button1 = new WxMenuButton();
		    button1.setType("click");
		    button1.setName("菜单1");
		    button1.setKey("key1");
		    WxMenuButton button2 = new WxMenuButton();
		    button2.setType("view");
		    button2.setName("不良事件");
		    button2.setUrl("http://dhcc123.duapp.com/wx/login/toLogin");
		    List<WxMenuButton> buttons=new ArrayList<WxMenuButton>();
	        buttons.add(button1);
	        buttons.add(button2);         
	        WxMenu menu=new WxMenu();
	        menu.setButtons(buttons);
	        System.out.println("===menu=="+menu);
		    wxMpService.menuCreate(menu);
		} catch (WxErrorException e) {
			e.printStackTrace();
		}
		
	}
}
